<template>
  <v-container fluid tag="section">
    <v-row>
      <v-col sm="12" md="12">
        <v-card
          icon="mdi-clipboard-text"
          class="px-md-5 py-md-3 pa-xs-0 mt-0 w-100 h-100"
        >
          <v-simple-table>
            <template v-slot:default>
              <tbody>
                <tr>
                  <td class="font-weight-bold" width="15%">主机名称：</td>
                  <td>{{ machineBaseInfo.hostName }}</td>
                  <td class="font-weight-bold" width="15%">主机IP：</td>
                  <td>{{ machineBaseInfo.hostIP }}</td>
                </tr>
                <tr>
                  <td class="font-weight-bold">操作系统：</td>
                  <td>{{ machineBaseInfo.systemOs }}</td>
                  <td class="font-weight-bold">运行环境：</td>
                  <td>{{ machineBaseInfo.jvmVersion }}</td>
                </tr>
                <tr>
                  <td class="font-weight-bold">CPU信息：</td>
                  <td colspan="3">{{ machineSysInfo.cpuInfo }}</td>
                </tr>
                <tr>
                  <td class="font-weight-bold">CPU核心数：</td>
                  <td>{{ machineSysInfo.processorCount }}</td>
                  <td class="font-weight-bold">CPU核心使用率：</td>
                  <td>{{ machineSysInfo.usageRate }}</td>
                </tr>
                <tr></tr>
                <tr>
                  <td class="font-weight-bold">程序运行时间：</td>
                  <td>{{ machineSysInfo.runDateTime }}</td>
                  <td class="font-weight-bold">程序开始运行时间：</td>
                  <td>{{ machineSysInfo.startTime }}</td>
                </tr>
                <tr>
                  <td class="font-weight-bold">闲置内存信息：</td>
                  <td>
                    {{ machineSysInfo.freeMemoryInfo }}
                  </td>
                  <td class="font-weight-bold">内存使用率：</td>
                  <td>
                    {{ machineSysInfo.usageMemoryRate }}
                  </td>
                </tr>
              </tbody>
            </template>
          </v-simple-table>
        </v-card>
      </v-col>
    </v-row>
  </v-container>
</template>

<script>
export default {
  name: "MonitorMachineIndex",
  data: () => ({
    machineBaseInfo: {
      hostName: "",
      hostIP: "",
      systemOs: "",
      jvmVersion: "",
    },
    machineSysInfo: {
      cpuInfo: "",
      processorCount: null,
      usageRate: "",
      runDateTime: "",
      startTime: "",
      freeMemoryInfo: "",
      usageMemoryRate: "",
    },
  }),
  // 进页面加载
  created() {
    this.loadMachineBaseInfo();
    this.loadMachineSysInfo();
  },
  methods: {
    // 加载数据方法
    loadMachineBaseInfo() {
      var that = this;
      that.request.get("/api/machine/getBaseInfo").then((res) => {
        that.machineBaseInfo = res.data;
      });
    },
    // 加载数据方法
    loadMachineSysInfo() {
      var that = this;
      that.request.get("/api/machine/getSysInfo").then((res) => {
        that.machineSysInfo = res.data;
      });
    },
  },
};
</script>

<style scoped>
</style>
